#ifndef OBJECTMANAGER_H
#define OBJECTMANAGER_H

#include "Object.h"


class ObjectManager
{



public:
    ObjectManager();
    virtual ~ObjectManager();

    void init();
    void update(double timeSinceLastFrame);
    void clear();


    Object* createObject(std::string _name, std::string _type, Ogre::Vector2 _position=Ogre::Vector2(0,0));


    void removeObject(Object* _item);
     void removeObject(std::string _name);

    std::list<Object*> getObjectsNear(Ogre::Vector3 _position, float _distance=2.0);
    std::list<Object*> getObjectsWithComponentNear(Ogre::Vector3 _position, float _distance, std::string _component);

    Object* createObjectFromXMLFile(Object* _obj, std::string _path);
    Object* loadFromXML(Object* _obj, TiXmlElement* parentElement);

    void giveOrderToGoTo(Ogre::Vector2 _position);
    void giveOrderMovableToGoTo(Object* _object, Ogre::Vector2 _position);

    Object* getPlayer()
    {
        return m_player;
    };

    void setPlayer(Object* _player){m_player=_player;};

    Object* getObjectFromName(std::string _name);



protected:
private:
    Object* m_player;

  //  std::list<Object*> m_tabObjects;
    std::map<std::string, Object*> m_tabObjects;


    bool m_isInitialized;
};

#endif // OBJECTMANAGER_H
